package com.ruoyi.food.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.food.mapper.TRedBlackMapper;
import com.ruoyi.food.object.TRedBlack;
import com.ruoyi.food.service.TRedBlackService;

@Service
public class TRedBlackServiceImpl extends ServiceImpl<TRedBlackMapper, TRedBlack> implements TRedBlackService {

	@Autowired
	private TRedBlackMapper tRedBlackMapper;

	@Override
	public int saveTRedBlack(List<TRedBlack> tRedBlacks) {
		// TODO Auto-generated method stub
		int sign = 1;
		if (!tRedBlacks.isEmpty()) {

			for (TRedBlack tRedBlack : tRedBlacks) {
				tRedBlackMapper.insertRedBlack(tRedBlack);
			}
			 //this.saveBatch(tRedBlacks);

		} else {
			sign = 0;
		}

		return sign;

	}

	@Override
	public List<TRedBlack> findTRedBlack(TRedBlack tRedBlack) {
		// TODO Auto-generated method stub
		return tRedBlackMapper.selectRedBlack(tRedBlack);
	}

	@Override
	public int updateRedBlack(TRedBlack tRedBlack) {
		// TODO Auto-generated method stub
		int sign = 1;
		try {
			// this.baseMapper.updateById(tRedBlack);
			tRedBlackMapper.updateRedBlack(tRedBlack);
		} catch (Exception e) {
			sign = 0;
			throw e;
		}
		return sign;
	}

	@Override
	public TRedBlack findRedBlackById(long listId) {
		// TODO Auto-generated method stub
		// return this.baseMapper.selectById(listId);
		return tRedBlackMapper.selectRedBlackById(listId);
	}

	@Override
	public int deleteRedBlack(long listId) {
		// TODO Auto-generated method stub
		int sign = 1;
		try {

			tRedBlackMapper.deleteRedBlack(listId);
		} catch (Exception e) {
			sign = 0;
			throw e;
		}

		return sign;
	}

	@Override
	public List<TRedBlack> findAllTRedBlack() {
		// TODO Auto-generated method stub
		return tRedBlackMapper.selectAllRedBlack();
	}

}
